_BROWSE = {
  showFiltering : function ()
  {
 	$("#filtering-options").toggle('blind');
  },
  deleteCar : function (id, effect)
  {
    $(".car-row-"+id).hide(effect);
	$.ajax({
	  type: "POST",
	  url: "/browse/delete",
	  data: { 'id' : id }
	})
	_CART.delItem(id);
  },
  skipChange : false,
  carsToChanged : function ()
  {
	if (_BROWSE.skipChange)
	  return;

    var from = parseInt($("#cars_aged_from").val());
    var to = parseInt($("#cars_aged_to").val());

	if (from >= to)
	{
	  _BROWSE.skipChange = true;
      $("#cars_aged_from").val(to-1);
	  _BROWSE.skipChange = false;
	}
  },
  carsFromChanged : function ()
  {
	if (_BROWSE.skipChange)
	  return;

    var from = parseInt($("#cars_aged_from").val());
    var to = parseInt($("#cars_aged_to").val());

	if (from >= to)
	{
	  _BROWSE.skipChange = true;
      $("#cars_aged_to").val(from+1);
	  _BROWSE.skipChange = false;
	}
  }
}

$(function () {
  $("#cars_aged_from").change(function() {
    _BROWSE.carsFromChanged();
  })

  $("#cars_aged_to").change(function() {
    _BROWSE.carsToChanged();
  })
})
